package com.bigdata.config;

import com.bigdata.server.ServerBootstrap;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class RpcRroviderConfig implements ApplicationContextAware {
    @Value("${rpc.host}")
    private String host;
    @Value("${rpc.port}")
    private int port;

    private ApplicationContext applicationContext;

    @PostConstruct
    public void serverBootstrap() throws InterruptedException {
        ServerBootstrap bootstrap = new ServerBootstrap(host,port,applicationContext);
        bootstrap.start();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext=applicationContext;
    }
}
